#!./perl

$file = "./le_list.txt";
#$file = "/solutions/.products/.bin/httpd/Solaris_2/le_list.txt";
$start = "yes";
$getum = "no";
$totalhits=0;
$tmphits = 0;

sub error
{
}

open(IN,$file) || die &error;
     while (<IN>) {
        @tmp = split(/\t/,$_);
        chop($_);
	  $getum = "yes";
	  if ($start eq "yes" && @tmp[0] ne "" ) { $company = $tmp[0];$getum = "no";$start = "no";}

          if (@tmp[0] ne ""  && $start ne "yes" ) {$companies{$company} =join(":",@urllist);$company=@tmp[0];$getum = "no";@urllist = ();} 
	  

	  if (@tmp[0] eq "" && $getum eq "yes") {
	      chop(@tmp[2]);
	      push(@urllist, "@tmp[1]:@tmp[2]");
	  }
     } 

$companies{$company} =join(":",@urllist);

close(IN);
        $~ = HTMLHEADER;
	write STDOUT;
     foreach $key  (sort keys(%companies)) {
	$realkey = $key;
	chop($key);
	@stats = split(/:/,$companies{$realkey});
	%final = @stats;
	print "<dt><b>$key</b><br>\n";
	while (($url, $hits) = each(%final)) {
		
	        $tmphits = ($tmphits + $hits);	
		$~ = EACHCOMP;
		write STDOUT;
	}
	$totalhits = ($totalhits + $tmphits);
	print "Total for $key: <b>$tmphits</b><br>\n";
	$tmphits = 0;
		
	#print "$key $companies{$realkey}\n";
     }
	$Final = $final{"chuck"};
	print "<dt>Total Hits: <b>$totalhits</b><br>\n";
	$~ = HTMLFOOTER;
	write STDOUT;




#######################################
#Formats
#######################################
format EACHCOMP =
<dd>          @<<<<<<<<<<<<<<<<<<<<<<<<<<<          @#####<br>
$url, $hits
.
##################################
format HTMLHEADER =
Content-type: text/html


 
<html>
<body>
<h1>Outside hits from the Sun Solutions CD</h1>
<dl>
.
##################################
format HTMLFOOTER =
</dl> 
</body>
</html>
.
